// Do not remove the include below
#include "ArdAvr_Blink.h"

#include "Timer.h"
#include "TimerAdapter.h"
#include "TimerContext.h"

const unsigned int  BLINK_TIME_MILLIS = 1000;
const int           LED_PIN           = 13;

bool ledStatus = false;

class BlinkTimerAdapter : public TimerAdapter
{
public:
  void timeExpired()
  {
    ledStatus = !ledStatus;
    digitalWrite(LED_PIN, ledStatus);
  }
};

Timer blinkTimer(new BlinkTimerAdapter(), Timer::IS_RECURRING, BLINK_TIME_MILLIS);

//The setup function is called once at startup of the sketch
void setup()
{
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, ledStatus);
}

// The loop function is called in an endless loop
void loop()
{
  // Kick the timer(s)
  TimerContext::instance()->handleTick();
}
